﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using RadarDLL.Entities;

namespace RadarDLL
{
    public class RadarXML
    {
        public static bool WriteXML(Radar Rad)
        {
            //Writes the numbers to an xml file
            #region SecondaryXML
            XmlDocument Rad_Information = new XmlDocument();

            XmlNode docNode = Rad_Information.CreateXmlDeclaration("1.0", "UTF-8", null);
            Rad_Information.AppendChild(docNode);
            XmlNode RadarNode = Rad_Information.CreateElement("Radar");
            Rad_Information.AppendChild(RadarNode);
            XmlNode BogieSpeed = Rad_Information.CreateElement("Speed");
            BogieSpeed.AppendChild(Rad_Information.CreateTextNode(Rad.Speed.ToString()));
            RadarNode.AppendChild(BogieSpeed);
            XmlNode BogieAlt = Rad_Information.CreateElement("Altitude");
            BogieAlt.AppendChild(Rad_Information.CreateTextNode(Rad.Altitude.ToString()));
            RadarNode.AppendChild(BogieAlt);
            XmlNode BogieDir = Rad_Information.CreateElement("Direction");
            BogieDir.AppendChild(Rad_Information.CreateTextNode(Rad.Direction.ToString()));
            RadarNode.AppendChild(BogieDir);
            XmlNode BogieDis = Rad_Information.CreateElement("Distance");
            BogieDis.AppendChild(Rad_Information.CreateTextNode(Rad.Distance.ToString()));
            RadarNode.AppendChild(BogieDis);
            XmlNode BogieThreat = Rad_Information.CreateElement("Threat_Level");
            BogieThreat.AppendChild(Rad_Information.CreateTextNode(Rad.Threatlevel.ToString()));
            RadarNode.AppendChild(BogieThreat);
            XmlNode RadarStatus = Rad_Information.CreateElement("Radar_Status");
            RadarStatus.AppendChild(Rad_Information.CreateTextNode("On"));
            RadarNode.AppendChild(RadarStatus);
            Rad_Information.Save("Radar.xml");
            #endregion
            return true;
        }
    }
}
